gdk: Add api to set drag window hotspot
authorMatthias Clasen <mclasen@redhat.com>
Tue, 8 Dec 2015 02:52:03 +0000 (21:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 8 Dec 2015 02:52:03 +0000 (21:52 -0500)
With GdkDragContext now being in charge of placing the window,
it needs to know about the hotspot to place under the cursor.

docs/reference/gdk/gdk3-sections.txt
gdk/gdkdnd.c
gdk/gdkdnd.h
gdk/gdkdndprivate.h

index b26ede0ae23c41e8b820bc20c4e8eed8152b5e27..a2ab5d8c17b53f04a34493d9bfa3c8c92c4d7909 100644 (file)
@@ -968,6 +968,7 @@ gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_protocol
 gdk_drag_context_get_drag_window
+gdk_drag_context_set_hotspot
 
 <SUBSECTION Standard>
 GDK_DRAG_CONTEXT
index 691b52bff5f7892bad85dedbe2b7480d39bbb87e..8a4559e2861b55b441a454015f04ac055a675c36 100644 (file)
@@ -480,3 +480,26 @@ gdk_drag_context_get_drag_window (GdkDragContext *context)
 
   return NULL;
 }
+
+/**
+ * gdk_drag_context_set_hotspot:
+ * @context: a #GdkDragContext
+ * @hot_x: x coordinate of the drag window hotspot
+ * @hot_y: y coordinate of the drag window hotspot
+ *
+ * Sets the position of the drag window that will be kept
+ * under the cursor hotspot. Initially, the hotspot is at the
+ * top left corner of the drag window.
+ *
+ * Since: 3.20
+ */
+void
+gdk_drag_context_set_hotspot (GdkDragContext *context,
+                              gint            hot_x,
+                              gint            hot_y)
+{
+  g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+
+  if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot)
+    GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y);
+}
index 4d2cd65a7d8111baf38cb3636e35895e40f7f2df..bcac0a6f9fb1db2df5815e56960918d28ffed9bb 100644 (file)
@@ -174,6 +174,11 @@ gboolean        gdk_drag_drop_succeeded (GdkDragContext *context);
 GDK_AVAILABLE_IN_3_20
 GdkWindow      *gdk_drag_context_get_drag_window (GdkDragContext *context);
 
+GDK_AVAILABLE_IN_3_20
+void            gdk_drag_context_set_hotspot (GdkDragContext *context,
+                                              gint            hot_x,
+                                              gint            hot_y);
+
 G_END_DECLS
 
 #endif /* __GDK_DND_H__ */
index be1626fcbd53508583dc180cb340e9852a6a7a36..e8a163f7c8c99eb0284fa6fb47090b952c8fe389 100644 (file)
@@ -63,6 +63,9 @@ struct _GdkDragContextClass {
                                 guint32          time_);
   gboolean    (*drop_status)   (GdkDragContext  *context);
   GdkWindow*  (*get_drag_window) (GdkDragContext *context);
+  void        (*set_hotspot)   (GdkDragContext  *context,
+                                gint             hot_x,
+                                gint             hot_y);
 };
 
 struct _GdkDragContext {